package org.example.design.chain.service;

import org.example.design.chain.bean.AuthInfo;

import java.util.Date;

/**
 * @Classname Level1AuthLink
 * @Description TODO
 * @Date 2020/11/6 11:21 上午
 * @Created by xiangjd
 */
public class Level1AuthLink extends AuthLink{

    public Level1AuthLink(String levelUserId, String levelUsername) {
        super(levelUserId, levelUsername);
    }

    @Override
    public AuthInfo doAuth(String uid, String orderId, Date authDate) {

        Date date = AuthService.queryAuthInfo(levelUserId, orderId);
        if (null == date) {
            return new AuthInfo("0001", "单号：", orderId, " 状态：待一级审批负责人 ", levelUsername);
        }
        AuthLink next = super.next();
        if (null == next) {
            return new AuthInfo("0000", "单号：", orderId, " 状态：一级审批完成负责人", " 时间：", f.format(date), " 审批人：", levelUsername);
        }
        return next.doAuth(uid, orderId, authDate);
    }
}
